const Router = require('koa-router')
const { verifyToken } = require('@/utils/jwt')
const examValidate = require('@/middlewares/validateMiddlewares/examValidate')
const {
  validateSlideCode
} = require('@/middlewares/validateMiddlewares/userValidate')
const examController = require('@/controller/examController')
const { verifyAdmin } = require('@/middlewares/validateMiddlewares/verifyAdmin')

const router = new Router()

/**
 * 根据ID获取试卷列表
 */
router.get(
  '/info',
  // verifyToken(),
  examController.getExamById
)

/**
 * 获取科目列表
 */
router.get(
  '/list',
  // verifyToken(),
  examValidate.listExamValidate,
  examController.listExam
)



/**
 * 创建科目列表
 */
router.post(
  '/create',
  verifyToken(),
  verifyAdmin(),
  examValidate.createExamValidate,
  examController.createExam
)

/**
 * 更新科目列表
 */
router.put(
  '/update',
  verifyToken(),
  verifyAdmin(),
  examValidate.updateExamValidate,
  examController.updateExam
)

/**
 * 删除科目列表
 */
router.delete(
  '/delete',
  validateSlideCode(),
  verifyToken(),
  verifyAdmin(),
  examValidate.delExamsValidate,
  examController.delExams
)

/**
 * 科目排序
 */
router.put(
  '/sort',
  verifyToken(),
  verifyAdmin(),
  examValidate.delExamsValidate,
  examController.sortExams
)

module.exports = router
